# -*- coding:utf-8 -*-
"""
作者：谷台阳
日期：2022年10月28日
"""
from openpyxl import Workbook
import pandas as pd

wb = Workbook()
sheet = wb.active
datas = None

with open("../../data/message.txt", "r") as op:
    data = op.readlines()
    t0, t1 = data[0].split(";  ")
    print(t0, t1)
    sheet.title = "clear"
    sheet["A1"] = t0
    sheet["B1"] = t1.strip('\n')

for i in range(1, len(data)):
    t0, t1, t2 = data[i].split("'")
    t3, t4 = t1.split(", ")
    t5 = t3.strip("im")
    row = str(i + 1)
    sheet["A" + row] = t5
    sheet["B" + row] = t4

op.close()
wb.save("clear.xlsx")

data = pd.read_excel("clear.xlsx", sheet_name="clear")
df = pd.DataFrame(data)
df.to_excel("origin.xlsx", index=False, sheet_name="origin")
df_1 = df.sort_values("Hidden  Message", ascending=True)
print(df_1)
df_1.to_excel("clear.xlsx", index=False, sheet_name="clear")

